Page({
  data: {
    activeTab: 'all',
    showFilter: false,
    tabs: [
      { label: '全部', value: 'all' },
      { label: '待付款', value: 'pending' },
      { label: '待收货', value: 'delivering' },
      { label: '待使用', value: 'unused' },
      { label: '退款/售后', value: 'after_sale' }
    ],
    orders: [] // 模拟数据见下方
  },

  // 初始化模拟数据
  onLoad() {
    this.setData({
      orders: this.getMockOrders()
    });
  },

  // 切换选项卡
  switchTab(e) {
    const value = e.currentTarget.dataset.value;
    this.setData({ activeTab: value });
    this.filterOrders(value);
  },

  // 显示筛选面板
  showFilter() {
    this.setData({ showFilter: true });
  },

  // 过滤订单
  filterOrders(status) {
    // 实际开发中应请求接口获取数据
    const allOrders = this.getMockOrders();
    const filtered = status === 'all' 
      ? allOrders 
      : allOrders.filter(item => item.status === status);
      
    this.setData({ orders: filtered });
  },

  // 订单跳转
  navigateToDetail(e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/order/detail?id=${id}`
    });
  },

  // 模拟数据
  getMockOrders() {
    return [
      // 模拟数据...
    ];
  }
});